package com.bbs.dao;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.bbs.bean.ReplyBBSOfPCAuto;
import com.car.util.ConnectionPool;
import com.car.util.Util;

public class ReplyDaoOfPCAuto {
	private Connection conn = ConnectionPool.getConnection("pcauto", "root", "zhouzhou100428", "192.168.1.168");

	public List<Integer> getUid() {
		List<Integer> list = new ArrayList<>();
		Statement st = null;
		ResultSet rs = null;
		String sql = "SELECT DISTINCT kb_yhid FROM pcauto_kb";
		try {
			st = conn.createStatement();
			rs = st.executeQuery(sql);
			while (rs.next()) {
				list.add(rs.getInt("kb_yhid"));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

	public void insertReply(ReplyBBSOfPCAuto rep) {
		PreparedStatement ps = null;
		String sql = "INSERT INTO pcauto_yh_hf(hf_yhid,hf_bbsid,hf_bt,hf_nr,hf_uid,hf_sj) VALUES(?,?,?,?,?,?)";
		try {
			ps = conn.prepareStatement(sql);
			ps.setInt(1, rep.getHf_yhid());
			ps.setInt(2, rep.getHf_bbsid());
			ps.setString(3, rep.getHf_bt());
			ps.setString(4, rep.getHf_nr());
			ps.setInt(5, rep.getHf_uid());
			ps.setDate(6, (Date) Util.getDate(rep.getHf_sj()));
			ps.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
